/**
 * 
 */
package com.org.javabody.implementsApi.implmentsDemo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * @author Administrator
 * 接口实际上就是预定义方法（相当于PPT模板,有共性的时候用interface）
 * 父类:
 * 父类不能加入其自身的构造函数，也不可用class修饰
 * 定义的方法不能用static修饰,可以加入abstract修饰,缺省方法前面默认是public
 * 变量隐式用public static final修饰(用private修饰会报错)
 * 方法隐式用public abstract修饰，其方法全部是抽象方法
 * 子类:
 * 接口父类的方法子类必须有
 * @author Administrator

 *

 */
interface Usb {
    int I = 1;
    void usbType();
    /* JDK1.8版本以后才能用dufault修饰，从而使得接口也能进行非抽象类实现

    default String getUsbName(String a){

    	return a;

    }

    */
}

abstract class LinkSataInterface {
	private final static Logger log = LoggerFactory.getLogger(LinkSataInterface.class); 
	public LinkSataInterface() {
		log.info("连接Sata接口中...");
	}
	public abstract void connect();
}


class Usb1 implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb1.class); 
	@Override
	public void usbType() {
	   log.info("USB1.0");
	}
}

class Usb2 implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb2.class); 
	@Override
	public void usbType() {
	   log.info("USB2.0");
	}
}

class Usb3 extends LinkSataInterface implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb3.class); 
	
	public void connect() {
		   log.info("可以连接SATA3接口");
	}
	
	@Override
	public void usbType() {
	   log.info("USB3.0");
	}
}

class Usb4 implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb4.class); 
	@Override
	public void usbType() {
	   log.info("USB4.0");
	}
}

class Usb5 implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb5.class); 
	@Override
	public void usbType() {
	   log.info("USB5.0");
	   log.info(I+"");
	}
}

class Usb6 implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb6.class); 
	
	public void connect() {
		   log.info("可以连接SATA3、6、9接口");
	}
	
	@Override
	public void usbType() {
	   log.info("USB6.0");
	}
}

class Usb7 extends LinkSataInterface implements Usb{
	private final static Logger log = LoggerFactory.getLogger(Usb7.class); 
	
	public void connect() {
		   log.info("可以连接SATA3、6、9接口");
	}
	
	@Override
	public void usbType() {
	   log.info("USB7.0");
	}
}



public class ImplmentsDemo {

	public static void main(String[] args) {
		Usb usb1 = new Usb1();	
		Usb usb2 = new Usb2();
		Usb usb3 = new Usb3();
		Usb usb4 = new Usb4();
		Usb usb5 = new Usb5();
		Usb usb6 = new Usb6();//不能访问子类中自定义的新方法(成员)

		Usb usb7 = new Usb7();
		usb1.usbType();
		usb2.usbType();
		usb3.usbType();
		usb4.usbType();
		usb5.usbType();
		
		usb6.usbType();//哪怕该子类中有自己写的一个方法，但父类却没有改方法，实例化时使用多态是找不到独立的方法的

		
		Usb6 usb = new Usb6();//实例化自身可以找到该方法

		usb.connect();
		usb.usbType();
		
		usb7.usbType();
		
		LinkSataInterface linkSata = new Usb7();
		linkSata.connect();
	}
}